package model;

import java.time.LocalDateTime;

public class Video {
    private String id;  // 移除了final修饰符
    private final String title;
    private final String filePath;
    private final String uploadTime;
    private int viewCount;
    private String thumbnailPath;

    // 构造方法
    public Video(String id, String title, String filePath) {
        this.id = id;
        this.title = title;
        this.filePath = filePath;
        this.uploadTime = LocalDateTime.now().toString();
        this.viewCount = 0;
    }

    // 新增无ID构造方法（用于数据库自增场景）
    public Video(String title, String filePath) {
        this(null, title, filePath); // ID设为null
    }

    // ===== Getter & Setter =====
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public String getFilePath() {
        return filePath;
    }

    public String getUploadTime() {
        return uploadTime;
    }

    public int getViewCount() {
        return viewCount;
    }

    public void incrementViewCount() {
        this.viewCount++;
    }

    public String getThumbnailPath() {
        return thumbnailPath;
    }

    public void setThumbnailPath(String path) {
        this.thumbnailPath = path;
    }

    // 可选：添加toString方法便于调试
    @Override
    public String toString() {
        return String.format("Video[id=%s, title=%s, path=%s]",
                id, title, filePath);
    }
}